home *** CD-ROM | disk | FTP | other *** search
- package TickerTapeComp;
-
- import com.netobjects.nfc.api.CStringArray;
- import com.netobjects.nfc.api.ComponentApp;
- import com.netobjects.nfc.api.DAssetManager;
- import com.netobjects.nfc.api.DDrawJava;
- import com.netobjects.nfc.api.DLayout;
- import com.netobjects.nfc.api.DRect;
- import com.netobjects.nfc.api.IDInspector;
- import java.util.ResourceBundle;
-
- public class TickerTapeComp extends ComponentApp {
- static final long serialVersionUID = -3238717140016679597L;
- int Speed;
- int Frame;
- int Background;
- int LED;
- int LEDType;
- int LEDSize;
- int numImages;
- int MaxImages;
- DAssetManager assetMan;
- DDrawJava theJavaApplet;
- String[] imageNames;
- int[] imageURLs;
- String[] linkTargets;
-
- void allocateImageArray(int n) {
- this.imageNames = new String[n];
- this.imageURLs = new int[n];
- this.linkTargets = new String[n];
-
- for(int cnt = 0; cnt < n; ++cnt) {
- this.imageURLs[cnt] = -1;
- this.imageNames[cnt] = "";
- this.linkTargets[cnt] = "";
- }
-
- }
-
- public void onCopy() {
- String[] imageNamesOld = this.imageNames;
- int[] imageURLsOld = this.imageURLs;
- this.allocateImageArray(this.MaxImages);
-
- for(int cnt = 0; cnt < this.numImages; ++cnt) {
- this.imageNames[cnt] = new String(imageNamesOld[cnt]);
- if (imageURLsOld[cnt] != 0 && imageURLsOld[cnt] != -1) {
- this.imageURLs[cnt] = imageURLsOld[cnt];
- this.assetMan.CopyAsset(imageURLsOld[cnt]);
- }
- }
-
- }
-
- public void onDrop(DLayout layout, DRect r, int fDrop) {
- try {
- if (fDrop != 1) {
- if (this.LEDSize == 0) {
- this.LEDSize = 2;
- }
-
- return;
- }
-
- this.numImages = 1;
- this.Speed = 25;
- this.Frame = 6;
- this.Background = 0;
- this.LED = 5;
- this.LEDType = 0;
- this.LEDSize = 2;
- this.allocateImageArray(this.MaxImages);
- this.theJavaApplet = new DDrawJava();
- this.theJavaApplet.setImageFile(this.theJavaApplet.getCodeBase() + "TickerTape.jpg");
- this.theJavaApplet.setStretch(2);
- this.theJavaApplet.setAppletFileName(this.theJavaApplet.getCodeBase() + "TickerTape.class");
- this.theJavaApplet.SetPositionRect(r.getLeft(), r.getTop(), r.getRight(), r.getBottom());
- layout.AddObject(this.theJavaApplet);
- } catch (Throwable var6) {
- }
-
- }
-
- protected void onFinalize() {
- for(int cnt = 0; cnt < this.numImages; ++cnt) {
- if (this.imageURLs[cnt] != 0 && this.imageURLs[cnt] != -1) {
- this.assetMan.RemoveAsset(this.imageURLs[cnt]);
- }
- }
-
- }
-
- public void onInspect(CStringArray Names, CStringArray Types) {
- Names.Set(ResourceBundle.getBundle("TickerTapeComp").getString("Number_of_Messages"));
- Types.Set("Collection");
-
- for(int cnt = 0; cnt < this.numImages; ++cnt) {
- Names.Set(ResourceBundle.getBundle("TickerTapeComp").getString("Text_for_Message") + " " + Integer.toString(cnt + 1));
- Types.Set("String");
- Names.Set(ResourceBundle.getBundle("TickerTapeComp").getString("URL_for_Message") + " " + Integer.toString(cnt + 1));
- Types.Set("Link");
- }
-
- Names.Set(ResourceBundle.getBundle("TickerTapeComp").getString("Speed"));
- Types.Set("Collection");
- Names.Set(ResourceBundle.getBundle("TickerTapeComp").getString("Frame_Color"));
- Types.Set("Set(" + ResourceBundle.getBundle("TickerTapeComp").getString("Color_List") + ")");
- Names.Set(ResourceBundle.getBundle("TickerTapeComp").getString("Background_Color"));
- Types.Set("Set(" + ResourceBundle.getBundle("TickerTapeComp").getString("Color_List") + ")");
- Names.Set(ResourceBundle.getBundle("TickerTapeComp").getString("LED_Color"));
- Types.Set("Set(" + ResourceBundle.getBundle("TickerTapeComp").getString("Color_List") + ")");
- Names.Set(ResourceBundle.getBundle("TickerTapeComp").getString("LED_Type"));
- Types.Set("Collection");
- Names.Set(ResourceBundle.getBundle("TickerTapeComp").getString("LED_Font_Size"));
- Types.Set("Collection");
- }
-
- public String onInstall(DAssetManager cam, String codeBase) {
- this.MaxImages = 50;
- this.assetMan = cam;
- return ResourceBundle.getBundle("TickerTapeComp").getString("Component_Name");
- }
-
- public void onPublish(DAssetManager asm, int context) {
- if (this.linkTargets == null) {
- this.linkTargets = new String[this.numImages];
-
- for(int i = 0; i < this.numImages; ++i) {
- this.linkTargets[i] = "";
- }
- }
-
- this.theJavaApplet.AddParam("speed", "int", Integer.toString(this.Speed));
- this.SetColor("framecolor", this.Frame);
- this.SetColor("backcolor", this.Background);
- this.SetColor("ledcolor", this.LED);
- if (this.LEDSize < 3 && this.LEDType == 1) {
- this.theJavaApplet.AddParam("ledtype", "int", "0");
- } else {
- this.theJavaApplet.AddParam("ledtype", "int", Integer.toString(this.LEDType));
- }
-
- if (this.LEDSize < 1) {
- this.LEDSize = 2;
- }
-
- this.theJavaApplet.AddParam("LEDsize", "int", Integer.toString(this.LEDSize));
-
- for(int cnt = 0; cnt < this.numImages; ++cnt) {
- this.theJavaApplet.AddParam("text" + Integer.toString(cnt + 1), "String", this.imageNames[cnt]);
- String theURL;
- if (this.imageURLs[cnt] != -1) {
- theURL = this.assetMan.GetAssetRelativeLocation(this.imageURLs[cnt], context, 1);
- } else {
- theURL = "";
- }
-
- this.theJavaApplet.AddParam("link" + Integer.toString(cnt + 1), "String", theURL);
- this.theJavaApplet.AddParam("target" + Integer.toString(cnt + 1), "String", this.linkTargets[cnt]);
- }
-
- }
-
- public void onUnInstall(DAssetManager cam) {
- }
-
- public String PropertyListener(String Event, String Value, int Get, int propIndex, IDInspector insp) {
- if (Get == 1) {
- if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("Number_of_Messages")) == 0) {
- return Integer.toString(this.numImages);
- }
-
- if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("Speed")) == 0) {
- return Integer.toString(this.Speed);
- }
-
- if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("Frame_Color")) == 0) {
- return Integer.toString(this.Frame);
- }
-
- if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("Background_Color")) == 0) {
- return Integer.toString(this.Background);
- }
-
- if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("LED_Color")) == 0) {
- return Integer.toString(this.LED);
- }
-
- if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("LED_Type")) == 0) {
- return Integer.toString(this.LEDType);
- }
-
- if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("LED_Font_Size")) == 0) {
- return Integer.toString(this.LEDSize);
- }
-
- for(int cnt = 0; cnt < this.numImages; ++cnt) {
- if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("Text_for_Message") + " " + Integer.toString(cnt + 1)) == 0) {
- return new String(this.imageNames[cnt]);
- }
-
- if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("URL_for_Message") + " " + Integer.toString(cnt + 1)) == 0) {
- return Integer.toString(this.imageURLs[cnt]);
- }
- }
- } else if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("Number_of_Messages")) == 0) {
- int newNumImages = Integer.parseInt(Value, 10);
- if (newNumImages < 1) {
- return "";
- }
-
- this.numImages = newNumImages;
- if (this.numImages > this.MaxImages) {
- this.numImages = this.MaxImages;
- }
-
- for(int i = newNumImages; i < this.MaxImages; ++i) {
- this.imageURLs[i] = -1;
- this.imageNames[i] = "";
- }
- } else if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("Speed")) == 0) {
- this.Speed = Integer.parseInt(Value, 10);
- if (this.Speed < 1) {
- this.Speed = 1;
- } else if (this.Speed > 50) {
- this.Speed = 50;
- }
- } else if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("Frame_Color")) == 0) {
- this.Frame = Integer.parseInt(Value, 10);
- } else if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("Background_Color")) == 0) {
- this.Background = Integer.parseInt(Value, 10);
- } else if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("LED_Color")) == 0) {
- this.LED = Integer.parseInt(Value, 10);
- } else if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("LED_Type")) == 0) {
- this.LEDType = Integer.parseInt(Value, 10);
- if (this.LEDType < 0) {
- this.LEDType = 0;
- } else if (this.LEDType > 2) {
- this.LEDType = 2;
- }
- } else if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("LED_Font_Size")) == 0) {
- this.LEDSize = Integer.parseInt(Value, 10);
- if (this.LEDSize < 1) {
- this.LEDSize = 1;
- } else if (this.LEDSize > 10) {
- this.LEDSize = 10;
- }
- } else {
- for(int cnt = 0; cnt < this.numImages; ++cnt) {
- if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("Text_for_Message") + " " + Integer.toString(cnt + 1)) == 0) {
- this.imageNames[cnt] = Value;
- }
-
- if (Event.compareTo(ResourceBundle.getBundle("TickerTapeComp").getString("URL_for_Message") + " " + Integer.toString(cnt + 1)) == 0) {
- this.imageURLs[cnt] = Integer.parseInt(Value, 10);
- if (this.assetMan.LinkHasFrames(this.imageURLs[cnt]) == 0) {
- this.linkTargets[cnt] = this.assetMan.GetTargetFromLink(this.imageURLs[cnt]);
- } else {
- this.linkTargets[cnt] = "";
- }
-
- if (this.imageURLs[cnt] != -1) {
- this.assetMan.GetAssetLocation(this.imageURLs[cnt], 0, 1);
- } else {
- String var10 = "";
- }
- }
- }
- }
-
- return "";
- }
-
- private void SetColor(String VarName, int SetVal) {
- if (SetVal == 0) {
- this.theJavaApplet.AddParam(VarName, "String", "black");
- } else if (SetVal == 1) {
- this.theJavaApplet.AddParam(VarName, "String", "blue");
- } else if (SetVal == 2) {
- this.theJavaApplet.AddParam(VarName, "String", "cyan");
- } else if (SetVal == 3) {
- this.theJavaApplet.AddParam(VarName, "String", "darkGray");
- } else if (SetVal == 4) {
- this.theJavaApplet.AddParam(VarName, "String", "gray");
- } else if (SetVal == 5) {
- this.theJavaApplet.AddParam(VarName, "String", "green");
- } else if (SetVal == 6) {
- this.theJavaApplet.AddParam(VarName, "String", "lightGray");
- } else if (SetVal == 7) {
- this.theJavaApplet.AddParam(VarName, "String", "magenta");
- } else if (SetVal == 8) {
- this.theJavaApplet.AddParam(VarName, "String", "orange");
- } else if (SetVal == 9) {
- this.theJavaApplet.AddParam(VarName, "String", "pink");
- } else if (SetVal == 10) {
- this.theJavaApplet.AddParam(VarName, "String", "red");
- } else if (SetVal == 11) {
- this.theJavaApplet.AddParam(VarName, "String", "white");
- } else if (SetVal == 12) {
- this.theJavaApplet.AddParam(VarName, "String", "yellow");
- }
-
- }
- }
-